$(function() {	
		
	gridObj = $.fn.bsgrid.init('g_tabYeh', {
		ajaxType : 'get',
		url :  server_url+'/rest/SpecialArticle/SpecialArticleList.do?ran=' + Math.random() + '&token=' + token,
		autoLoad : true,
		pageSizeSelect : true,
		stripeRows : true,
		pageSize : 10,
		displayBlankRows : false,
		isProcessLockScreen : true,
		rowSelectedColor : false,
		showPageToolbar:true
	});
});


function operate(record, rowIndex, colIndex, options) {	
    return '<a href="javascript:EditSpecialArticle(\'' + gridObj.getRecordIndexValue(record, 'id') + '\');">编辑</a>';		
}



//数据表格参数查询
function doSearch() {
	searchParames = $('#myform').serialize();	
	if ($('#title').val() == '') {
		gridObj.search('');
	} else {
		gridObj.search(searchParames);
	}	
}

//添加
function toSpecialArticleAdd(){

	var url="goSpecialArticleAdd.do?ran="+Math.random();
	tl_config.loadToWorkArea(url);
}

// 编辑
function EditSpecialArticle(id) {
	//alert(id);
	var url='goSpecialArticleEdit.do?id='+id;
	tl_config.loadToWorkArea(url);
}

//获取checkbox选中删除
function delCheckedIds() {
	// values are array
	var ids = gridObj.getCheckedValues('id').toString();
	if (ids == "") {
		easyDialog.open({
			container:{
				header:'温馨提示',
				content:"请选择要操作的记录！"
			},
			autoClose : 2000
		});
	} else {
		easyDialog.open({
			  container : {
				header:'温馨提示',
			    content : '您确定要删除吗？',
			    yesFn : function(){
			    	$.ajax({
						url : server_url+'/rest/SpecialArticle/SpecialArticleDel.do',
						type : 'post',
						dataType : 'json',
						data : {
							updateUser:username,
							ids : ids,
							token:token
						},
						success : function(data) {
							if (data.retCode = "0000") {								
								var url="getSpecialArticleListPage.do?ran="+Math.random();
								tl_config.loadToWorkArea(url);
							} else{
								easyDialog.open({
									container:{header:'温馨提示',content:data.retMsg},
									autoClose : 2000
								});
							}  
						}
					});
			    },
			    noFn : true
			  }
			});
		
	}
}